//
//  ZZFArticlePlayCell.m
//  YYUDemo
//
//  Created by zsp on 2017/3/17.
//  Copyright © 2017年 zsp. All rights reserved.
//

#import "ZZFArticlePlayCell.h"

#import <Masonry.h>

#import "ZZFConfigSet.h"
#import "UIColor+ZZFExtend.h"

@interface ZZFArticlePlayCell ()

@property(nonatomic, strong)UIProgressView *articleProgressView;
@property(nonatomic, strong)UILabel *articleStartLabel;
@property(nonatomic, strong)UILabel *articleEndLabel;
@property(nonatomic, strong)UIButton *articlePlayButton;

@end

@implementation ZZFArticlePlayCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configView];
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)updateData:(id)data atIndexPath:(NSIndexPath*)indexPath {
    if (data) {
        
    }else{
        self.articleStartLabel.text=@"00:00";
        self.articleEndLabel.text=@"60:12";
    }
    
}

- (void)configView {
    self.articleProgressView=[[UIProgressView alloc] init];
    self.articleProgressView.progress=0.5f;
    
    self.articleStartLabel=[UILabel new];
    self.articleStartLabel.font=[UIFont systemFontOfSize:fontSize_11];
    self.articleStartLabel.textColor=[UIColor colorWithHexString:colorHex_subtitle_gray_1];
    
    self.articleEndLabel=[UILabel new];
    self.articleEndLabel.font=[UIFont systemFontOfSize:fontSize_11];
    self.articleEndLabel.textAlignment=NSTextAlignmentRight;
    self.articleEndLabel.textColor=[UIColor colorWithHexString:colorHex_subtitle_gray_2];
    
    self.articlePlayButton=[UIButton buttonWithType:UIButtonTypeCustom];
    [self.articlePlayButton setImage:[UIImage imageNamed:@"play"] forState:UIControlStateNormal];
    [self.articlePlayButton setImage:[UIImage imageNamed:@"play_no"] forState:UIControlStateDisabled];
    [self.articlePlayButton setImage:[UIImage imageNamed:@"pause"] forState:UIControlStateSelected];
    
    UIView *supView=self.contentView;
    [supView addSubview:self.articleProgressView];
    [supView addSubview:self.articleStartLabel];
    [supView addSubview:self.articleEndLabel];
    [supView addSubview:self.articlePlayButton];
    
    [self.articleProgressView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(supView).offset(15);
        make.trailing.equalTo(supView).offset(-15);
        make.top.equalTo(supView).offset(10);
        make.height.mas_equalTo(15);
    }];
    
    [self.articleStartLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.articleProgressView.mas_bottom).offset(5);
        make.leading.equalTo(self.articleProgressView);
        make.width.mas_equalTo(100);
    }];
    
    [self.articleEndLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.articleProgressView.mas_bottom).offset(5);
        make.trailing.equalTo(self.articleProgressView);
        make.width.mas_equalTo(100);
    }];
    
    [self.articlePlayButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.articleProgressView.mas_bottom).offset(15);
        make.centerX.equalTo(self.articleProgressView);
        make.width.height.mas_equalTo(40);
    }];
    
    [self updateData:nil atIndexPath:nil];
}
@end
